﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace GU.WebERP.Core.Common
{
    /// <summary>
    /// 数据库连接
    /// </summary>
    public class JnsDbConnection
    {
        /// <summary>
        /// 初始化数据库连接
        /// </summary>
        public static void Initialize()
        {
            JnsFramework.DataProvide.DatabaseFactory.AddConnStr("GU.ERPDb", ConfigurationManager.AppSettings["GU.ERPDb"],
                                                                JnsFramework.DBFramework.Common.DBType.SQLServer);

            JnsFramework.DataProvide.DatabaseFactory.AddConnStr("GU.WeiXinDb", ConfigurationManager.AppSettings["GU.WeiXinDb"],
                                                                 JnsFramework.DBFramework.Common.DBType.SQLServer);

            string defaultDb = ConfigurationManager.AppSettings["DefaultDb"];
            if (string.IsNullOrEmpty(defaultDb))
            {
                throw new Exception("Web.Config 中 DefaultDb 结点不能为空");
            }
            JnsFramework.DataProvide.DatabaseFactory.SetDefaultConnStr(defaultDb);
        }
    }
}
